Skip to content

Conversation

jakubno
Copy link
Member

@jakubno jakubno commented Oct 10, 2025

  • Add addons table
  • Simplifies types for team, moves the querying to db and types to dedicated module, limits the usage of generated types

Note

Adds "addons" table and computed team_limits view, replaces Tier with unified Team + TeamLimits types across API/auth/handlers/orchestrator, and updates queries/cache accordingly.

  • DB/Schema:
    • Add public.addons table and team_limits view aggregating tier limits + active addons.
    • Replace tier-based queries with new teams__get.sql returning Team + TeamLimit; remove old tier query files.
  • API/Types/DB:
    • Introduce internal/db/types: Team, TeamLimits, TeamWithDefault; helpers NewTeam, GetTeamsByUser.
    • Update DB accessors (GetTeamAuth, GetTeamByIDAndUserIDAuth) to return *types.Team.
  • Auth/Cache:
    • Refactor team auth cache to store *types.Team (drop tier from cache API).
    • Authentication middleware/function signatures updated to use *types.Team.
  • Handlers:
    • Replace GetTeamAndTier with GetTeamAndLimits; propagate *types.Team through all sandbox/template endpoints.
    • Enforce timeouts and resource limits via team.Limits.
  • Orchestrator/Template:
    • Use team.Limits for concurrency checks and sandbox/build params.
    • team.LimitResources now accepts *types.TeamLimits.
  • Models/Ent:
    • Remove Tier schema and generated code; simplify Team (tier remains string field only).
    • Cleanup LaunchDarkly context to send tier name from Team and team/cluster contexts.
  • Misc:
    • Logging and analytics updated to work with new *types.Team.

Written by Cursor Bugbot for commit 6cdf1cd. This will update automatically on new commits. Configure here.

@jakubno jakubno added the improvement Improvement for current functionality label Oct 10, 2025
Copy link

linear bot commented Oct 10, 2025

@jakubno jakubno force-pushed the refactor-api-to-use-the-new-add-ons-table-eng-3069 branch 5 times, most recently from 61c521c to dd8cc31 Compare October 13, 2025 08:21
@jakubno jakubno marked this pull request as ready for review October 13, 2025 09:53
@sitole sitole self-assigned this Oct 13, 2025
cursor[bot]

This comment was marked as outdated.

@jakubno jakubno force-pushed the refactor-api-to-use-the-new-add-ons-table-eng-3069 branch from a006852 to bd08a5e Compare October 15, 2025 08:38
AND addon.valid_from <= now()
AND (addon.valid_to IS NULL OR addon.valid_to > now())
) a ON true
WHERE ut.user_id = $1 AND t.id = $2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create view that will precalculate addon values per team so we dont need to do this sum in multiple queries?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe sqlc comes with some way how to re-use part of query

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, this simplified few things <3

ctx := c.Request.Context()

teams, err := a.sqlcDB.GetTeamsWithUsersTeamsWithTier(ctx, userID)
teams, err := dbapi.GetTeamByUser(ctx, a.sqlcDB, userID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTeamByUser -> GetTeamsByUser

@jakubno jakubno force-pushed the refactor-api-to-use-the-new-add-ons-table-eng-3069 branch from bd08a5e to 36351ab Compare October 15, 2025 11:46
@jakubno jakubno requested a review from sitole October 15, 2025 11:47
cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants